package net.wanho.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

@Configuration
public class ResourcesConfig implements WebMvcConfigurer {
    //本地文件上传路径
    @Value("${file.path}")
    private String localFilePath;
    //本地文件上传前缀
    @Value("${file.prefix}")
    private String localFilePrefix;

    @Value("${file.domain}")
    private String domain;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(localFilePrefix+"/**")
                .addResourceLocations("file:"+localFilePath+ File.separator);
    }
}
